var t = getApp(), a = t.require("utils/onfire.js");

Page({
    data: {
        devicePosition: "back",
        hasPhotoed: !1,
        screenWidth: t.globalData.systemInfo.windowWidth,
        screenHeight: t.globalData.systemInfo.windowHeight,
        imageSrc: null,
        photoType: "idcard"
    },
    onLoad: function(t) {
        t.src && t.src.length ? this.setData({
            hasPhotoed: !0,
            imageSrc: t.src,
            photoType: t.type
        }) : this.setData({
            photoType: t.type
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {},
    onSwitch: function() {
        var t = this;
        t.setData({
            devicePosition: "back" == t.data.devicePosition ? "front" : "back"
        });
    },
    onPhoto: function() {
        var t = this;
        wx.createCameraContext().takePhoto({
            success: function(a) {
                t.setData({
                    imageSrc: a.tempImagePath,
                    hasPhotoed: !0
                });
            }
        });
    },
    onConfirm: function() {
        var t = this, e = wx.createCanvasContext("canvasId");
        e.drawImage(t.data.imageSrc, 0, 0, t.data.screenWidth, t.data.screenHeight), e.draw(), 
        wx.canvasToTempFilePath({
            canvasId: "canvasId",
            success: function(t) {
                a.fire("CardPhoto", t.tempFilePath), wx.navigateBack();
            }
        });
    },
    onRevert: function() {
        this.setData({
            imageSrc: null,
            hasPhotoed: !1
        });
    }
});